package org.example.myspringboot.exception;

import org.example.myspringboot.pojo.ResponseMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice //统一处理
public class AllExceptionHandlerAdvice {
Logger log = LoggerFactory.getLogger(AllExceptionHandlerAdvice.class);
  @ExceptionHandler(value = Exception.class)
    public ResponseMessage handleAllException(Exception e) {

        log.error("统一异常",e);
        return new ResponseMessage(500,"error",null);
    }
}
